home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 2.6 KB | 90 lines | [TEXT/CWIE] |
- /*
- File: ProviderFactory.c
-
- Contains: Sample that shows how to use OTTransferProviderOwnership.
-
- Written by: Quinn "The Eskimo!"
-
- Copyright: Copyright © 1997-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/23/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- ////////////////////////////////////////////////////////////
- // Pick up general Open Transport stuff.
-
- #include <OpenTransport.h>
-
- ////////////////////////////////////////////////////////////
- // Pick up OT debugging macros.
-
- #include <OTDebug.h>
-
- ////////////////////////////////////////////////////////////
- // Get our own prototype.
-
- #include "ProviderFactory.h"
-
- ////////////////////////////////////////////////////////////
- // OTDebugStr is not defined in any of the interfaces,
- // but it is in the libraries.
-
- extern void OTDebugStr(char *str);
-
- ////////////////////////////////////////////////////////////
-
- static Boolean gOTInited = false;
-
- ////////////////////////////////////////////////////////////
- // Provider factory routines.
-
- extern OSStatus FactoryCreateEndpoint(EndpointRef *ref, OTClient *currentOwner)
- // See comment in interface part.
- // In this example, we arbitrarily create an ADSP endpoint. This
- // technique works for all types of endpoints.
- {
- OSStatus err;
-
- OTAssert("FactoryCreateEndpoint: Parameter error", ref != nil);
- OTAssert("FactoryCreateEndpoint: Parameter error", currentOwner != nil);
- OTAssert("FactoryCreateEndpoint: Called but we weren't successfully inited.", gOTInited);
-
- *currentOwner = OTWhoAmI();
- *ref = OTOpenEndpoint(OTCreateConfiguration("adsp"), 0, nil, &err);
-
- return err;
- }
-
- ////////////////////////////////////////////////////////////
- // Initialisation and termination routines.
-
- extern OSStatus InitProviderFactory(void)
- // See comment in interface part.
- {
- OSStatus err;
-
- err = InitOpenTransport();
- gOTInited = (err == noErr);
-
- return err;
- }
-
- extern void CloseProviderFactory(void)
- // See comment in interface part.
- {
- OTAssert("CloseProviderFactory: Called but we weren't successfully inited.", gOTInited);
- if (gOTInited) {
- CloseOpenTransport();
- }
- }
-